package com.wll.ec;

import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;

import com.wll.ec.core.activities.ProxyActivity;
import com.wll.ec.core.app.Ec;
import com.wll.ec.core.delegates.EcBaseDelegate;
import com.wll.ec.core.ui.luancher.ILauncherListener;
import com.wll.ec.core.ui.luancher.OnLauncherFinishTag;
import com.wll.ec.fast.login.ISignListener;
import com.wll.ec.fast.login.SignInDelegate;
import com.wll.ec.fast.main.EcBottomDelegate;

import cn.jpush.android.api.JPushInterface;
import qiu.niorgai.StatusBarCompat;

/**
 * Created by detachment on 2020/3/10
 */
public class EcActivity extends ProxyActivity implements ISignListener, ILauncherListener {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        Ec.getConfigurator().withWeChatActivity(this);
        StatusBarCompat.translucentStatusBar(this, true);
    }

    @Override
    protected void onPause() {
        super.onPause();
        JPushInterface.onPause(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        JPushInterface.onResume(this);
    }

    @Override
    public EcBaseDelegate setRootDelegate() {
        return new EcBottomDelegate();
    }

    @Override
    public void onSignInSuccess() {
        Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSignUpSuccess() {
        Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onLauncherFinish(OnLauncherFinishTag tag) {
        switch (tag) {
            case SIGNED:
                Toast.makeText(this, "启动完成，用户登录了", Toast.LENGTH_SHORT).show();
//                getSupportDelegate().startWithPop(new EcBottomDelegate());
                getSupportDelegate().replaceFragment(new EcBottomDelegate(), false);
                break;
            case UN_SIGNED:
                Toast.makeText(this, "启动完成，用户未登录", Toast.LENGTH_SHORT).show();
//                getSupportDelegate().startWithPop(new SignInDelegate());
                getSupportDelegate().replaceFragment(new SignInDelegate(), false);
                break;
            default:
                break;
        }
    }
}
